package com.bw.mapper;

import com.bw.bean.Vo;
import com.bw.bean.Vo1;
import com.bw.bean.Vo2;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VoMapper {

    @Select("select s.name,\n" +
            "       sum(oi.original_amount) value,\n" +
            "       count(p.id)num,\n" +
            "       count(oi.shop_id)num1,\n" +
            "       sum(oi.actual_amount)sum,\n" +
            "       sum(p.amount)sum1\n" +
            "from  order_info oi\n" +
            "left join order_detail od on oi.id = od.order_info_id\n" +
            "left join customer c on od.customer_id = c.id\n" +
            "left join payment p on c.id = p.customer_id\n" +
            "left join shop s on oi.shop_id = s.id\n" +
            "left join product_sku ps on od.product_sku_id = ps.id\n" +
            "left join product_spu p2 on ps.product_spu_id = p2.id\n" +
            "group by s.name;")
    List<Vo1> getList1();

    @Select("select\n" +
            "       date(oi.create_time)times,\n" +
            "       p2.name,\n" +
            "       sum(oi.original_amount)value\n" +
            "       from order_info oi\n" +
            "left join order_detail od on oi.id = od.order_info_id\n" +
            "left join customer c on od.customer_id = c.id\n" +
            "left join payment p on c.id = p.customer_id\n" +
            "left join shop s on oi.shop_id = s.id\n" +
            "left join product_sku ps on od.product_sku_id = ps.id\n" +
            "left join product_spu p2 on ps.product_spu_id = p2.id\n" +
            "group by p2.name,times;")
    List<Vo2> getList2();
}
